#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QObject>
#include <QTimer>
#include <QTcpSocket>
#include <QDebug>

#include "BasePort.h"

class TCPClient : public BasePort
{
    Q_OBJECT

public:
    Q_INVOKABLE  TCPClient(QObject *parent = 0);
    ~TCPClient();

    void setPortParam(PortStruct portParam);
    void open();
    void close();
    void write(PortStruct target,QByteArray data);



private:

    QTcpSocket *tcpClient;
    QTimer *reconnectTimer;
    int reconnectTimeout;


private slots:
    void readyReadSlot();
    void disconnectedSlot();
    void connectedSlot();
    void timeoutSlot();


};

#endif // TCPCLIENT_H
